%=============================================================
% Function to create the HMM Model from the given data for two 
% gestures and write a .mat file containing the trained model
%=============================================================
%function k=save_training_data(leftData,rightData,idleData,NUM_MIX,NUM_STATES,NUM_ITER,INIT_TYPE)
function save_training_data(data,NUM_MIX,NUM_STATES,NUM_ITER,INIT_TYPE)

    % Packs the gestureData cell array (to be used for training)
    gestureData = {};
    for i=1:numel(data)
       gestureData{i} = {};
       curData = data{i};
       for j=1:numel(curData)
          curMat = getMatrix(curData{j});
          gestureData{i}{j} = curMat;
       end
    end
     
    init_params.NumMix = NUM_MIX; % no. components in mixtures
    init_params.NumStates = NUM_STATES; % no. of states
    init_params.NumIter = NUM_ITER; % max. no. of EM iterations
    init_params.InitType = INIT_TYPE; %initialize from uniform probabilities
    
    model = train_multiclass_hmm(gestureData,init_params);
    
    save('model.mat','model');

end